/*
 * Copyright 2002-2006 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.tigris.jasmincc.framework;

import java.util.*;

import org.tigris.jasmincc.framework.exception.ParserClassAlreadyExistedException;
import org.tigris.mappedlexer.io.*;

/**
 * Core model for representing a JavaCC source.
 * 
 * @author Sam Huang
 * 
 */
public interface JavaCCModel {

	/**
	 * Add a Java code block.
	 * 
	 * @param javaBlock
	 */
	void addJavaBlock(String javaBlock);

	/**
	 * Get a new method stream sequence.
	 * 
	 * @return
	 */
	CharOutputSequence addJavaCode();

	/**
	 * Add an import statement.
	 * 
	 * @param javaImport
	 */
	void addJavaImport(String javaImport);

	/**
	 * Get a new method stream sequence.
	 * 
	 * @return
	 */
	CharOutputSequence addMethod();

	/**
	 * Add a new token to MORE.
	 * 
	 * @param name
	 * @param value
	 * @deprecated
	 */
	@Deprecated
	void addMore(String name, String value, String stmt);

	/**
	 * Add a new option.
	 * 
	 * @param name
	 * @param value
	 */
	void addOption(String name, String value);

	/**
	 * Add a new RegexRegion.
	 * 
	 * @param rr
	 */
	public void addRegexRegion(RegexRegion rr);

	/**
	 * Add a new skip token.
	 * 
	 * @param skip
	 */
	@Deprecated
	void addSkip(String skip);

	/**
	 * Add a new special token.
	 * 
	 * @param name
	 * @param value
	 * @deprecated
	 */
	@Deprecated
	void addSpecialToken(String name, String value, String stmt);

	/**
	 * Add a new token.
	 * 
	 * @param name
	 * @param value
	 * @deprecated
	 */
	@Deprecated
	void addToken(String name, String value, String stmt);

	/**
	 * Add a new token manager declaration.
	 * 
	 * @param name
	 * @param value
	 * @deprecated
	 */
	@Deprecated
	void addTokenManagerDeclaration(String name, String value, String stmt);

	/**
	 * Get the file name of the JavaCC source file.
	 * 
	 * @return
	 */
	String getFileName();

	/**
	 * @return the javaBlocks
	 */
	public List<String> getJavaBlocks();

	/**
	 * @return the javaImports
	 */
	public List<String> getJavaImports();

	/**
	 * @return the methods
	 */
	public List<CharOutputSequence> getMethods();

	/**
	 * @return the options
	 */
	public Properties getOptions();

	/**
	 * Get the parser class defined in an external file.
	 * 
	 * @return
	 * @throws ParserClassAlreadyExistedException
	 */
	CharOutputSequence getParserClass()
			throws ParserClassAlreadyExistedException;

	/**
	 * Get the skips.
	 * 
	 * @return
	 */
	List<String> getSkips();

	/**
	 * @return the specialTokens
	 */
	public Properties getSpecialTokens();

	/**
	 * @return the tokenManagerDeclaration
	 */
	public Properties getTokenManagerDeclaration();

	/**
	 * Get the tokens.
	 * 
	 * @return
	 */
	Properties getTokens();

	/**
	 * Returns true if it is a JJTree source file.
	 * 
	 * @return
	 */
	boolean isTree();

	/**
	 * Emits the JavaCC source code.
	 * 
	 * @return
	 * @throws Exception
	 */
	JavaCCFile render() throws Exception;

	void setDefaultParserHandler(DefaultParserHandler handler);

	/**
	 * Set the grammar name of the JavaCC source.
	 * 
	 * @param grammarName
	 */
	void setGrammarName(String grammarName);

	/**
	 * Set the grammar is to generate a JJTree.
	 * 
	 * @param tree
	 */
	void setTree(boolean tree);
}
